<?php 
//include "includes/session.php";
include "includes/comunes.php";
ini_set('max_execution_time', 60000);
//error_reporting(E_ALL);
ini_set('memory_limit','360M');
if($_GET['submit']){
//me conecto a access
$men="";
$sql="select * from sucursales";
$res=cons_sql_up($sql);
$i=0;
 while($reg=mysql_fetch_array($res)){
    //echo $reg['sucursalConexion'];die();
	$ult_id= obtener_ultimo_id($reg['sucursalId']);
	$conn_access = odbc_connect ($reg['sucursalConexion'], "", "");
	$sqlFic="select * from Checkinout where Logid > ".$ult_id;
	//echo $sqlFic;die();
	$resBD=odbc_exec($conn_access,$sqlFic);
	while ($valor = odbc_fetch_array($resBD)){
			insertar_fichada($reg['sucursalId'],$valor['Userid'],$valor['CheckTime'],$valor['CheckType'],$valor['Logid']);
			$i++;
		}
    $ult_id_suc_ext= ult_id_suc_ext($reg['sucursalId']);
	actualizar_id_ext($reg['sucursalId'],$ult_id_suc_ext);
	$men.="Sucursal ".$reg['sucursalId']." Cantidad ".$i;
}
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta HTTP-EQUIV="refresh" CONTENT="300"/>
<title>Sistema de Registro de Atencion</title>

<link href="estilos.css" rel="stylesheet" type="text/css" />

<!--libreria jquery central-->

<script src="jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->

<!--Librerias para el combo-->
<script language="JavaScript" type="text/javascript" src="combos/jquery.chainedSelects.js"></script>
<!--fin libreria-->

<!--librerias ui-->
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->
<!--libreria flexigrid-->
<link rel="stylesheet" type="text/css" href="jquery-ui/css/ui-flexigrid/flexigrid.css">
    <script type="text/javascript" src="jquery-ui/js/flexigrid.js"></script>
<!--fin libreria-->
<!--VENTANA MODAL -->
<link href="modal/styles/modal-window.css" type="text/css" rel="stylesheet" /> 
 
		<script type="text/javascript" language="javascript" src="modal/scripts/modal-window.min.js"></script>  


<script language="JavaScript" type="text/javascript">
$(function()
{


       $( "#fecha" ).datepicker({
         dateFormat: "yy-mm-dd"

      });
       $( "#fechah" ).datepicker({
         dateFormat: "yy-mm-dd"

      });
      $( "#fechapla" ).datepicker({
         dateFormat: "yy-mm-dd"

      });
//             funcion


	  $( "#menu" ).menu({position: {at: "left bottom"}});
});
</script>



</head>

<body>

<div class="container">
<?php include "includes/head.php"?>
   <div class="content">
       <div class="tituloprincipal"><img src="img/pedidos.jpg" width="25" height="25" border="0"/> Importar Fichadas
           <?php include 'includes/submenu.php';?>  
           </div>
       
       <div class="contenedorpedido">
       <form id="altapedido" name="altapedido" method="GET" action="index.php">
        <fieldset>
             <legend><b>Seleccione Opcion</b></legend>
             <table>
                <tr>
				<td class="textotablamenuform"><?php echo $men;?></td>
				</tr>
                 <!--<tr>
                     <td class="textotablamenuform">Sucursal a Asociar</td>
                     <td class="textotablamenuform">
                        <select name="sucursal" id="sucursal" class="campo_form">
                             <option selected value="0">Todos...</option>
                             <?php
                             //$ped=obtener_sucursales();

                            // while($regPed=mysql_fetch_array($ped)){
                                 
                              //         echo "<option value='".utf8_encode($regPed['sucursalId'])."'>".utf8_encode($regPed['sucursalNombre'])." (".utf8_encode($regPed['sucursalCodigo']).")</option>";


                             //}

                             ?>

                         </select>
                     </td>
                    
                     <td class="textotablamenuform">Fecha Desde</td>
                     <td class="textotablamenuform"><input type="text" name="fecha" id="fecha" value="" class="campo_form" /></td>
					  <td class="textotablamenuform">Fecha Hasta</td>
                    <td class="textotablamenuform"><input type="text" name="fechah" id="fechah" value="" class="campo_form" /></td>
                 </tr>-->
                 
						
                
                   <tr>
                    <td class="textotablamenuform" style="text-align: right;" colspan="8">
                         <input type="reset" name="enviar" value="Limpiar"  class="boton_form"/>
                         <input name="submit" id="submit" type="submit" value="Importar" class="boton_form"/>
                     </td>
                 </tr>
             </table>
        </fieldset>
       </form>
          
           
       </div>
 
       <div class="clear"></div>
   <br>
   </div>
  <?php include "includes/pie.php"?>
  
</div>


</body>
</html>
